<html>
<head>
    <title>register</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

</head>
<body>




<form class="form-horizontal" action="register.php" method="post" id="form">
    <div class="form-group">
        <label for="ACCOUNT" class="col-sm-2 control-label">ACCOUNT</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="ACCOUNT"  name="username" placeholder="USERNAME">
        </div>
    </div>
    <div class="form-group">
        <label for="psd" class="col-sm-2 control-label">Password</label>
        <div class="col-sm-10">
            <input type="password" class="form-control" name="password" id="psd" placeholder="Password">
        </div>
    </div>
    <div class="form-group">
        <label for="rpsd" class="col-sm-2 control-label">RePassword</label>
        <div class="col-sm-10">
            <input type="password" class="form-control" id="rpsd" placeholder="Password" onmouseout="IsConsistentPasswd()"><span id="checkPasswd" style="color: brown"></span><br>
        </div>
    </div>
    <div class="form-group">
        <label for="ACCOUNT" class="col-sm-2 control-label">Email</label>
        <div class="col-sm-10">
            <input type="email" class="form-control" id="email"  name="username" placeholder="Email" onmouseout="IsEmail()"><span id="checkEmail" style="color: brown"></span><br>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default"  onclick="CheckRegisterInfo()">Sign in</button>
        </div>
    </div>
</form>
<script>
/*��ע��Ĺ���*/

    function  IsConsistentPasswd() {
        var  passwd1 = document.getElementById("psd");
        var  passwd2 = document.getElementById("rpsd");
        var checks=document.getElementById("checkPasswd");

        if ((passwd1.value=="") ||(passwd2.value=="")){
            checks.innerHTML="密码不能为空";
            return false;

        }

        if(passwd1.value != passwd2.value) {
            checks.innerHTML="密码不一致";
            return false;

        }else{
            checks.innerHTML="";
            return true;
        }
    }
    function IsEmail(){  //�ж������ʽ��ȷ��
        var email= document.getElementById("email");
        var emailReg = /^(\w){3,20}@[a-z0-9]+(\.[a-z]+){1,3}$/;
        var checks=document.getElementById("checkEmail");


        if(!emailReg.test(email.value)){
            checks.innerHTML="邮箱不符合要求";
            return false;
        }else{
            checks.innerHTML="";
            return true;

        }
    }
    function CheckRegisterInfo() {
        var  registerform=document.getElementById("form");
        if(!IsConsistentPasswd() || !IsEmail())
        {
            return;
        }
        else {
            registerform.submit();
        }
    }

</script>

</body>
</html>